package edu.lsnu.equipment_management_system.mapper.update;

import edu.lsnu.equipment_management_system.pojo.vo.sql_conditions.DateAndEquipmentNoVo;
import edu.lsnu.equipment_management_system.pojo.vo.sql_conditions.UserNoEquipmentNoAndDateVo;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author mzy
 * @Description 管理员所有审核
 * @date 2018/11/20
 */
public interface AdminReviewMapper {
    /*
    -- 管理员审核
    -- 转置回null
    update JBXX_DRDC set SHR = null
            , SHRQ = null
            -- 先查出管理员的名字
    select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01'
    */

    /*
      -- 1.管理员：报损报废的审核
      update JBXX_BSBF set SHR = (select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01')
      , SHRQ = GETDATE() where JBXX_BSBF.SBBH = '20030819'
     */
    /**
     * @Description 1.管理员：报损报废审核
     * @author mzy
     * @time 2018-11-21
     * @see
     * @return   int
     * @params  [equipmentNo]
     */
    @Update("update JBXX_BSBF set SHR = " +
            "(select TOP 1 YHB.XM " +
            "from YHB " +
            "where YHB.YHLBDM = '01')\n" +
            ", SHRQ = GETDATE() " +
            "where JBXX_BSBF.SBBH = #{equipmentNo}")
    int adminDamageReview(String equipmentNo); // 20030819


    /*
    -- 2.管理员：调入的审核
    update JBXX_DRDC set SHR = (select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01')
    , SHRQ = GETDATE() where JBXX_DRDC.SBBH = '20030818' and JBXX_DRDC.DCDR = '调入'
    */
    /**
     * @Description 2.管理员：调入的审核
     * @author mzy
     * @time 2018-11-21
     * @see 
     * @return   int
     * @params  [equipmentNo]
     */
    @Update("update JBXX_DRDC set SHR = " +
            "(select TOP 1 YHB.XM " +
            "from YHB " +
            "where YHB.YHLBDM = '01')\n" +
            ", SHRQ = GETDATE() " +
            "where JBXX_DRDC.SBBH = #{equipmentNo} " +
            "and JBXX_DRDC.DCDR = '调入'")
    int adminTransferInReview(String equipmentNo); // 20030818

    /*
    -- 3.管理员：调出的审核
    update JBXX_DRDC set SHR = (select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01')
    , SHRQ = GETDATE() where JBXX_DRDC.SBBH = '20030817' and JBXX_DRDC.DCDR = '调出'
    */
    /**
     * @Description 3.管理员：调出的审核
     * @author mzy
     * @time 2018-11-21
     * @see 
     * @return   int
     * @params  [equipmentNo]
     */
    @Update("update JBXX_DRDC set SHR = " +
            "(select TOP 1 YHB.XM " +
            "from YHB " +
            "where YHB.YHLBDM = '01')\n" +
            ", SHRQ = GETDATE() " +
            "where JBXX_DRDC.SBBH = #{equipmentNo} " +
            "and JBXX_DRDC.DCDR = '调出'")
    int adminTransferOutReview(String equipmentNo); // 20030817

    /*
    -- 4.管理员：设备购入审核
    update JBXX_SB set SHR = (select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01')
    , SHRQ = GETDATE() where JBXX_SB.SBBH = '20020152'
    */
    /**
     * @Description 4.管理员：设备购入审核
     * @author mzy
     * @time 2018-11-21
     * @see 
     * @return   int
     * @params  [equipmentNo]
     */
    @Update("update JBXX_SB set SHR = " +
            "(select TOP 1 YHB.XM " +
            "from YHB " +
            "where YHB.YHLBDM = '01')\n" +
            ", SHRQ = GETDATE() " +
            "where JBXX_SB.SBLY = '购入' and JBXX_SB.SBBH = #{equipmentNo}\n")
    int adminPurchaseReview(String equipmentNo); // 20020152

    /*
    -- 5.管理员：设备使用审核(需要用设备编号和开始时间一起约束)
    update JBXX_SBSY set SHR = (select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01')
    , SHRQ = GETDATE() where JBXX_SBSY.SBBH = '20020152' and SYRQ1 = '2017-01-01'
    */
    /**
     * @Description 5.管理员：设备使用审核(需要用设备编号和开始时间一起约束)
     * @author mzy
     * @time 2018-11-21
     * @see 
     * @return   int
     * @params  [dateAndEquipmentNoVo]
     */
    @Update("update JBXX_SBSY set SHR = " +
            "(select TOP 1 YHB.XM " +
            "from YHB " +
            "where YHB.YHLBDM = '01')\n" +
            ", SHRQ = GETDATE() " +
            "where JBXX_SBSY.SBBH = #{equipmentNo} and SYRQ1 = #{date}")
    int adminUseRecordReview(DateAndEquipmentNoVo dateAndEquipmentNoVo); // 20020152 / 2017-01-01

    /*
    -- 6.管理员：设备维护维修审核(需要用设备编号和开始时间一起约束)
    update JBXX_WHWX set SHR = (select TOP 1 YHB.XM from YHB where YHB.YHLBDM = '01')
    , SHRQ = GETDATE() where JBXX_WHWX.SBBH = '20030817' and XHRQ1 = '2018-10-30'
    */
    /**
     * @Description  6.管理员：设备维护维修审核(需要用设备编号和开始时间一起约束)
     * @author mzy
     * @time 2018-11-21
     * @see
     * @return   int
     * @params  [dateAndEquipmentNoVo]
     */
    @Update("update JBXX_WHWX set SHR = " +
            "(select TOP 1 YHB.XM " +
            "from YHB " +
            "where YHB.YHLBDM = '01')\n" +
            ", SHRQ = GETDATE() " +
            "where JBXX_WHWX.SBBH = #{equipmentNo} and XHRQ1 = #{date}")
    int adminRepairReview(DateAndEquipmentNoVo dateAndEquipmentNoVo); // 20030817 / 2018-10-30

    
}
